package weaver.interfaces.jjy.duss.hr;

import com.sap.mw.jco.JCO;
import weaver.interfaces.jjy.duss.util.SAPConnPool;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: ecology-9-demo
 * @description: SAP-OA编制主管架构
 * @author: Dusongsong
 * @create: 2019-12-07
 */

public class ZFM_HR_BZ_ZGJG {
    public JCO.Table  execute(Map<String, String> map) {
        SAPConnPool SAPConn = new SAPConnPool();
        JCO.Client myConnection = SAPConn.getConnection();
        JCO.Function bapi = SAPConn.excuteBapi("ZFM_HR_BZ_ZGJG");
        JCO.ParameterList input = bapi.getImportParameterList();//输入参数和结构处理
        JCO.ParameterList inputtable = bapi.getTableParameterList();//输入表的处理
        //输入参数
        input.setValue(map.get("IV_BMBM"),"IV_BMBM");//部门ID
        input.setValue(map.get("IV_DATUM"),"IV_DATUM");//日期
        input.setValue(map.get("IV_MBXL"),"IV_MBXL");//模版序列
        input.setValue(map.get("IV_NUMID"),"IV_NUMID");//OA流程ID
        //执行函数
        myConnection.execute(bapi);
        JCO.ParameterList out = bapi.getExportParameterList();//输出参数和结构处理
        JCO.ParameterList Table00 = bapi.getTableParameterList();//输出表的处理

        //返回处理结果以及日志
        JCO.Table tabs = Table00.getTable("ET_NEW");
        System.out.println("SPA_COUNTS:"+tabs.getNumRows());
        //返回处理结果以及日志
        JCO.Structure stu = out.getStructure("EV_OUTPUT");
        Map<String, String> mapreturn = new HashMap<>();
        String flag = (String) stu.getValue("ZFLAG");
        String message = (String) stu.getValue("ZMESG");
        mapreturn.put("flag", flag);
        mapreturn.put("message", message);
        System.out.println(mapreturn.toString());
        JCO.releaseClient(myConnection);
        return tabs;
    }
}
